package com.lucky.auth_boot.controller;

import com.lucky.auth_boot.common.Result;
import com.lucky.auth_boot.pojo.dto.DomainDTO;
import com.lucky.auth_boot.pojo.dto.DomainIsShowDTO;
import com.lucky.auth_boot.pojo.po.DomainPO;
import com.lucky.auth_boot.service.DomainService;
import com.lucky.auth_boot.pojo.vo.DomainCheckInfo;
import jakarta.annotation.Resource;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/domain")
public class DomainController {
    @Resource
    private DomainService domainService;

    @GetMapping("/getEmpowerUrlList")
    public Result<List<DomainPO>> getAuthList() {
        return Result.success(domainService.queryDomainList());
    }

    @GetMapping("/getEmpowerUrl")
    public Result<DomainCheckInfo> getEmpowerDomain(@RequestParam("domain") String domain) {
        return Result.success(domainService.queryDomainByName(domain));
    }

    @GetMapping("/getEmpowerUrlById")
    public Result<DomainPO> getEmpowerUrlById(@RequestParam("id") Integer id) {
        return Result.success(domainService.queryDomainById(id));
    }

    @DeleteMapping("/deleteEmpowerUrl")
    public Result<?> deleteEmpowerUrl(@RequestParam("id") Integer id) {
        return Result.success(domainService.deleteDomainById(id));
    }

    @DeleteMapping("/deleteEmpowerDomain")
    public Result<?> deleteEmpowerDomain(@RequestParam("id") Integer id) {
        return Result.success(domainService.deleteDomainByIds(id));
    }

    @PutMapping("/putEmpowerUrlInfo")
    public Result<?> putEmpowerUrlInfo(@RequestBody DomainPO domainPO) {
        return Result.success(domainService.updateDomainInfoById(domainPO));
    }

    @PostMapping("/postEmpowerUrl")
    public Result<?> postEmpowerDomain(@RequestBody DomainPO domainPO) {
        return Result.success(domainService.addDomain(domainPO));
    }

    @GetMapping("/queryEmpowerListPage")
    public Result<?> queryEmpowerListPage(Pageable pageable, DomainDTO domainDTO) {
        return Result.success(domainService.queryDomainListPage(pageable, domainDTO));
    }

    @GetMapping("/queryDomainOneById")
    public Result<?> queryDomainOneById(@RequestParam("id") Integer id) {
        return Result.success(domainService.queryDomainOneById(id));
    }

    @PutMapping("/putEmpowerUrlIsShow")
    public Result<?> putEmpowerUrlIsShow(@RequestBody DomainIsShowDTO domainIsShowDTO) {
        return Result.success(domainService.putEmpowerUrlIsShow(domainIsShowDTO));
    }

}
